package fr.univ.lr.icone.gui.zonerender;

import java.awt.Color;

/**
 * Defines relations between opinion and agent color
 * 
 * @author Elian ORIOU
 * 
 */

public class ColorOpinionMapping {

	private static final Color OPINION_COLOR_0 = Color.GRAY;
	private static final Color OPINION_COLOR_1 = Color.DARK_GRAY;
	private static final Color OPINION_COLOR_2 = Color.CYAN;
	private static final Color OPINION_COLOR_3 = Color.BLUE;
	private static final Color OPINION_COLOR_4 = Color.GREEN;
	private static final Color OPINION_COLOR_5 = Color.YELLOW;
	private static final Color OPINION_COLOR_6 = Color.ORANGE;
	private static final Color OPINION_COLOR_7 = Color.RED;
	private static final Color OPINION_COLOR_8 = Color.MAGENTA;
	private static final Color OPINION_COLOR_9 = Color.BLACK;

	/**
	 * Returns the color that matches the opinion
	 * 
	 * @param opinion
	 * @return
	 */

	public static Color getColor(int opinion) {
		switch (opinion) {
		case 0:
			return OPINION_COLOR_0;
		case 1:
			return OPINION_COLOR_1;
		case 2:
			return OPINION_COLOR_2;
		case 3:
			return OPINION_COLOR_3;
		case 4:
			return OPINION_COLOR_4;
		case 5:
			return OPINION_COLOR_5;
		case 6:
			return OPINION_COLOR_6;
		case 7:
			return OPINION_COLOR_7;
		case 8:
			return OPINION_COLOR_8;
		case 9:
			return OPINION_COLOR_9;
		}
		return null;
	}

	/**
	 * Returns the opinion that matches to the color
	 * 
	 * @param color
	 * @return
	 */

	public static int getOpinion(Color color) {
		if (color.equals(OPINION_COLOR_0)) {
			return 0;
		} else if (color.equals(OPINION_COLOR_1)) {
			return 1;
		} else if (color.equals(OPINION_COLOR_2)) {
			return 2;
		} else if (color.equals(OPINION_COLOR_3)) {
			return 3;
		} else if (color.equals(OPINION_COLOR_4)) {
			return 4;
		} else if (color.equals(OPINION_COLOR_5)) {
			return 5;
		} else if (color.equals(OPINION_COLOR_6)) {
			return 6;
		} else if (color.equals(OPINION_COLOR_7)) {
			return 7;
		} else if (color.equals(OPINION_COLOR_8)) {
			return 8;
		} else if (color.equals(OPINION_COLOR_9)) {
			return 9;
		}
		return -1;
	}
}
